const express = require('express')

const app = express()

app.use(require('cors')())

// 链接数据库
const mongoose = require('mongoose')
mongoose.connect("mongodb://localhost:27017/blog-admin", {
    useCreateIndex: true,
    useFindAndModify: true,
    useNewUrlParser: true,
})

//定义数据操作的模型
const Article = mongoose.model('Article',new mongoose.Schema({
    title:{ type: String },
    body: { type: String }
}))

app.get('/',(req,res)=>{
    res.send('index')
})

app.listen(3000,()=>{
    console.log('3000-服务已启动...')
})
